package com.windfone.web.action;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.windfone.model.Ad;
import com.windfone.service.CommonService;

public class AdmangerAction extends ActionSupport {
	/**	serialVersionUID */
	private static final long serialVersionUID = 1L;
	private CommonService commonService;
	private List<Ad>  ads;
	private  int adId;
	private Ad adBean;
	private String imagepath;
	private String target;
	private String url;
	private String text;
	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public String getImagepath() {
		return imagepath;
	}

	public String getTarget() {
		return target;
	}

	public String getUrl() {
		return url;
	}

	public void setImagepath(String imagepath) {
		this.imagepath = imagepath;
	}

	public void setTarget(String target) {
		this.target = target;
	}

	public void setUrl(String url) {
		this.url = url;
	}


	public Ad getAdBean() {
		return adBean;
	}

	public void setAdBean(Ad adBean) {
		this.adBean = adBean;
	}

	public int getAdId() {
		return adId;
	}

	public void setAdId(int adId) {
		this.adId = adId;
	}

	public List<Ad> getAds() {
		return ads;
	}

	public void setAds(List<Ad> ads) {
		this.ads = ads;
	}

	public void setCommonService(CommonService commonService) {
		this.commonService = commonService;
	} 
 
	public String execute() throws Exception {
		return SUCCESS;
	}
	public String adAtionList() throws Exception {
		ads = commonService.getAllAds();
		return SUCCESS;
	}
	public String beforeUpdateAd() throws Exception {
		adBean = commonService.getAdById(adId);
		return SUCCESS;
	}
	
	public String updateAd() throws Exception {
		adBean = new Ad();
		adBean.setImagepath(imagepath);
		adBean.setTarget(target);
		adBean.setUrl(url);
		adBean.setText(text);
		adBean.setId(adId);
		commonService.updateAd(adBean);
		return SUCCESS;
	}

}
